home *** CD-ROM | disk | FTP | other *** search
- program TstCF;
-
- {$apptype console}
-
- uses
- SysUtils,
- Classes,
- AACpndF;
-
- procedure PrintFolder(var aDirEntry : TaaCFDirEntry;
- var aStopWalk : boolean);
- begin
- if (aDirEntry.deType = detFolder) then
- writeln('folder: ', aDirEntry.deName)
- else
- writeln('file: ', aDirEntry.deName);
- end;
-
-
- var
- CF : TaaCompoundFile;
- SF : TaaSubfileStream;
- FS : TFileStream;
- Test1Folder : TaaHandle;
- Test2Folder : TaaHandle;
- begin
- writeln('create a new compound file');
- CF := nil;
- try
- CF := TaaCompoundFile.Create('c:\CF.DAT', fmCreate);
- finally
- CF.Free;
- end;
-
- writeln('open an existing empty compound file');
- CF := nil;
- try
- CF := TaaCompoundFile.Create('c:\CF.DAT', fmOpenReadWrite);
- writeln('add /test1 folder');
- Test1Folder := CF.AddFolder(CF.Root, 'test1');
- writeln('add /test1/test2 folder');
- Test2Folder := CF.AddFolder(Test1Folder, 'test2');
- writeln('dir listing of /test1');
- CF.WalkFolder(Test1Folder, PrintFolder);
- writeln('..end');
- writeln('dir listing of /test1/test2');
- CF.WalkFolder(Test2Folder, PrintFolder);
- writeln('..end');
- CF.CloseFolder(Test1Folder);
- CF.CloseFolder(Test2Folder);
- finally
- CF.Free;
- end;
-
- writeln('open an existing compound file');
- CF := nil;
- try
- CF := TaaCompoundFile.Create('c:\CF.DAT', fmOpenReadWrite);
- writeln('open /test1 folder');
- Test1Folder := CF.OpenFolder(CF.Root, 'test1');
- writeln('open /test1/test2 folder');
- Test2Folder := CF.OpenFolder(Test1Folder, 'test2');
- writeln('dir listing of /test1');
- CF.WalkFolder(Test1Folder, PrintFolder);
- writeln('..end');
- writeln('dir listing of /test2');
- CF.WalkFolder(Test2Folder, PrintFolder);
- writeln('..end');
-
- writeln('create new subfile');
- SF := TaaSubfileStream.Create(CF, Test2Folder, 'SomeFile', true);
- try
-
- writeln('write to subfile');
- FS := TFileStream.Create('AAIntLst.pas', fmOpenRead);
- try
- SF.CopyFrom(FS, FS.Size);
- finally
- FS.Free;
- end;
-
- finally
- writeln('free subfile');
- SF.Free;
- end;
-
- CF.CloseFolder(Test1Folder);
- CF.CloseFolder(Test2Folder);
- finally
- CF.Free;
- end;
-
- writeln('open an existing compound file with subfile');
- CF := nil;
- try
- CF := TaaCompoundFile.Create('c:\CF.DAT', fmOpenReadWrite);
- writeln('open /test1 folder');
- Test1Folder := CF.OpenFolder(CF.Root, 'test1');
- writeln('open /test1/test2 folder');
- Test2Folder := CF.OpenFolder(Test1Folder, 'test2');
- writeln('dir listing of /test1');
- CF.WalkFolder(Test1Folder, PrintFolder);
- writeln('..end');
- writeln('dir listing of /test2');
- CF.WalkFolder(Test2Folder, PrintFolder);
- writeln('..end');
-
- writeln('open existing subfile');
- SF := TaaSubfileStream.Create(CF, Test2Folder, 'SomeFile', false);
- try
-
- writeln('read from subfile');
- FS := TFileStream.Create('c:\test.pas', fmCreate);
- try
- SF.Seek(0, soFromBeginning);
- FS.CopyFrom(SF, SF.Size);
- finally
- FS.Free;
- end;
-
- finally
- writeln('free subfile');
- SF.Free;
- end;
-
- CF.CloseFolder(Test1Folder);
- CF.CloseFolder(Test2Folder);
- finally
- CF.Free;
- end;
-
-
- readln;
- end.
-